Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relay selector evaluates only first location constraint when a custom list is selected #5874

Conversation

rablador
Copy link
Contributor

@rablador rablador commented Feb 28, 2024

Fixes the bug by evaluating all locations before returning the result.


This change is Reviewable

@rablador rablador force-pushed the relay-selector-evaluates-only-first-location-constraint-when-ios-525 branch from 6287c3a to 999ca63 Compare February 28, 2024 11:51
@rablador rablador added the iOS Issues related to iOS label Feb 28, 2024
Copy link
Contributor

@acb-mv acb-mv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @rablador)


ios/MullvadREST/Relay/RelaySelector.swift line 157 at r1 (raw file):

                return true
            case let .only(relayConstraint):
                // At least one location must match the relay under test.

There's a lot of logic in this loop; wouldn't it make sense to move it to RelayLocation, perhaps a RelayWithLocation.matches(Location) method or similar?

Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @acb-mv)


ios/MullvadREST/Relay/RelaySelector.swift line 157 at r1 (raw file):

Previously, acb-mv wrote…

There's a lot of logic in this loop; wouldn't it make sense to move it to RelayLocation, perhaps a RelayWithLocation.matches(Location) method or similar?

Yeah, that's a good idea I think. I 'll look at it 👍

Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @acb-mv)


ios/MullvadREST/Relay/RelaySelector.swift line 157 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

Yeah, that's a good idea I think. I 'll look at it 👍

Can you create a test case that fails with the previous version, and is fixed by the changes here ?

Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @acb-mv)


ios/MullvadREST/Relay/RelaySelector.swift line 157 at r1 (raw file):

Previously, buggmagnet wrote…

Can you create a test case that fails with the previous version, and is fixed by the changes here ?

Sure thing.

Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @acb-mv)


ios/MullvadREST/Relay/RelaySelector.swift line 157 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

Sure thing.

In order to create such a test I need to make this function internal rather than private. I can't rely on on testing evaluate above, since the result will be random each time.

@rablador rablador force-pushed the relay-selector-evaluates-only-first-location-constraint-when-ios-525 branch from 999ca63 to 382e316 Compare March 1, 2024 15:43
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 3 files at r2, all commit messages.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @acb-mv)

Copy link
Contributor

@acb-mv acb-mv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion

@buggmagnet buggmagnet force-pushed the relay-selector-evaluates-only-first-location-constraint-when-ios-525 branch from 382e316 to 7ef5b77 Compare March 4, 2024 16:02
@buggmagnet buggmagnet merged commit 5418208 into main Mar 4, 2024
4 of 5 checks passed
@buggmagnet buggmagnet deleted the relay-selector-evaluates-only-first-location-constraint-when-ios-525 branch March 4, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS Issues related to iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants